<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>google-cloud-java</title>
        <meta name="description" content="Java idiomatic client for Google Cloud services">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="shortcut icon" href="https://cloud.google.com/images/gcp-favicon.ico">
        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/github.min.css">
        <link rel="stylesheet" href="css/site.css">
        <script src="js/vendor/modernizr-2.6.2.min.js"></script>
        <link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono|Roboto:300,400,700,700italic,400italic|Open+Sans:300' rel='stylesheet' type='text/css'>
    </head>
    <body ng-app="gcloud-java">
        <header class="page-header" role="banner">
            <h1 class="logo"><img src="img/logo-full.svg" alt="Google Cloud Platform" /></h1>
            <nav class="main-nav">
                <div class="nav-current">Java</div>
                <ul class="menu">
                    <li>
                        <a href="//googlecloudplatform.github.io/google-cloud-dotnet/" title="google-cloud-dotnet">
                            <img src="img/icon-lang-dotnet.svg" alt="google-cloud-dotnet" class="menu-icon" />
                            .NET
                        </a>
                    </li>
                    <li>
                        <a href="//googlecloudplatform.github.io/google-cloud-go/" title="google-cloud-go">
                            <img src="img/icon-lang-go.svg" alt="google-cloud-go" class="menu-icon" />
                            Go
                        </a>
                    </li>
                    <li>
                        <a href="#" title="google-cloud-java">
                            <img src="img/icon-lang-java-duke-white.svg" alt="google-cloud-java" class="menu-icon" width="24" height="24" />
                            Java
                        </a>
                    </li>
                    <li>
                        <a href="https://googlecloudplatform.github.io/google-cloud-node/" title="google-cloud-node">
                            <img src="img/icon-lang-nodejs.svg" alt="google-cloud-node" class="menu-icon" />
                            Node.js
                        </a>
                    </li>
                    <li>
                        <a href="https://googlecloudplatform.github.io/google-cloud-php/" title="google-cloud-php">
                            <img src="img/icon-lang-php.svg" alt="google-cloud-php" class="menu-icon" />
                            PHP
                        </a>
                    </li>
                    <li>
                        <a href="https://googlecloudplatform.github.io/google-cloud-python/" title="google-cloud-python">
                            <img src="img/icon-lang-python.svg" alt="google-cloud-python" class="menu-icon" />
                            Python
                        </a>
                    </li>
                    <li>
                        <a href="https://googlecloudplatform.github.io/google-cloud-ruby/" title="google-cloud-ruby">
                            <img src="img/icon-lang-ruby.svg" alt="google-cloud-ruby" class="menu-icon" />
                            Ruby
                        </a>
                    </li>
                </ul>
            </nav><!-- end of .main-nav -->
        </header><!-- end of .page-header -->


        <article class="main" role="main">
            <section class="hero-banner">
                <div class="container clearfix">
                    <div class="col col-left">
                        <h1>google-cloud</h1>
                        <p>Google Cloud Client Library for Java - an idiomatic, intuitive, and natural way for Java developers to integrate with Google Cloud Platform services, like Cloud Datastore and Cloud Storage.</p>
                    </div><!-- end of .col.col-left -->
                    <div class="col col-right">
                        <h2>Quickstart with Maven: add google-cloud to your pom.xml</h2>
                        <pre>&lt;dependency&gt;
  &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
  &lt;artifactId&gt;google-cloud&lt;/artifactId&gt;
  &lt;version&gt;{{SITE_VERSION}}&lt;/version&gt;
&lt;/dependency&gt;</pre>
                    </div><!-- end of .col.col-right -->
                </div><!-- end of .container -->
            </section><!-- end of .hero-banner -->

            <section class="block featuring">
                <div class="container">
                    <ul class="featuring-links">
                        <li>
                            <a href="./apidocs/index.html" title="google-cloud docs" class="btn btn-docs">
                                <img src="img/icon-lang-java-duke.svg" alt="Java icon" class="menu-icon" />
                                Read the Docs
                            </a>
                        </li>
                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/google-cloud-java" title="google-cloud on Github" class="ext-link">
                                <img src="img/icon-link-github.svg" alt="Github icon" />
                                Github
                            </a>
                        </li>
                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/google-cloud-java/issues" title="google-cloud issues on Github" class="ext-link">
                                <img src="img/icon-link-github.svg" alt="Github icon" />
                                Issues
                            </a>
                        </li>
                        <li>
                            <a href="https://stackoverflow.com/questions/tagged/google-cloud-platform+java" title="google-cloud on StackOverflow" class="ext-link">
                                <img src="img/icon-link-stackoverflow.svg" alt="StackOverflow icon" />
                                StackOverflow
                            </a>
                        </li>
                        <li>
                            <a href="./project-info.html" title="Java package manager" class="ext-link">
                                 <img src="img/icon-link-package-manager.svg" alt="Package Manager icon" />
                                Package Information
                            </a>
                        </li>
                    </ul>
                </div><!-- end of .container -->
            </section><!-- end of .featuring -->

            <section class="block about">
                <div class="container clearfix">
                <div class="quote-box">
                  <h3 class="block-title">What is it?</h3>

                  <p><code>google-cloud</code> is a client library for accessing Google
		    Cloud Platform services that significantly reduces the boilerplate
		    code you have to write. The library provides high-level API
		    abstractions so they're easier to understand. It embraces
		    idioms of Java, works well with the standard library, and
		    integrates better with your codebase.
		    All this means you spend more time creating code that matters
		    to you.</p>

		  <p><code>google-cloud</code> is configured to access Google Cloud Platform
		    services and authorize (OAuth 2.0) automatically on your behalf.
		    Add the <code>google-cloud</code> dependency to your project and get a private key to be
		    up and ready to go. Better yet, if you are running on Google
		    App Engine or Compute Engine, the private key is automatically detected.
                </div>

                <div class="quote-box--supplementary">
                  <h4>Example: Retrieve Datastore Entries</h4>

                    <div class="code-sample-tabs" ng-init="selected = 'compute engine'">
                      <a ng-click="selected = 'compute engine'" ng-class="{selected: selected == 'compute engine'}" class="selected">Run in Compute/App Engine</a>
                      <a ng-click="selected = 'elsewhere'" ng-class="{selected: selected == 'elsewhere'}">Run elsewhere</a>
                    </div>

                    <div hljs="" language="java" ng-show="selected == 'compute engine'" class=""><pre>
<code class="hljs java">import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.DatastoreOptions;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.KeyFactory;

// Authentication is automatic inside Google Compute Engine
// and Google App Engine.
Datastore datastore =
  DatastoreOptions.getDefaultInstance().getService();
KeyFactory keyFactory = datastore.newKeyFactory().setKind(<span class="hljs-string">KIND</span>);
Key key = keyFactory.newKey(keyName);
Entity entity = datastore.get(key);


</code></pre></div>

                    <div hljs="" language="java" ng-show="selected == 'elsewhere'" class=""><pre>
<code class="hljs java">import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.DatastoreOptions;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.KeyFactory;

DatastoreOptions options = DatastoreOptions.newBuilder()
  .setProjectId(<span class="hljs-string">PROJECT_ID</span>)
  .setCredentials(GoogleCredentials.fromStream(
    new FileInputStream(<span class="hljs-string">PATH_TO_JSON_KEY</span>))).build();
Datastore datastore = options.getService();
KeyFactory keyFactory = datastore.newKeyFactory().setKind(<span class="hljs-string">KIND</span>);
Key key = keyFactory.newKey(keyName);
Entity entity = datastore.get(key);
</code></pre></div>
                </div>
                </div><!-- end of .container -->
            </section><!-- end of .featuring -->

            <section class="block examples">
                <div class="container clearfix">
                    <h3 class="block-title">Examples</h3>

                    <ul>
                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf"><code>Bookshelf</code></a> - An App Engine app that manages a virtual bookshelf using google-cloud libraries for Datastore and Storage.
                        </li>

                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/flexible/datastore"><code>Flexible Environment/Datastore example</code></a> - A simple app that uses Cloud Datastore to list the last 10 IP addresses that visited your site.  Read about how to run the application <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/flexible/README.md">here</a>.
                        </li>
                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/flexible/cloudstorage"><code>Flexible Environment/Storage example</code></a> - An app that uploads files to a public Cloud Storage bucket on the App Engine Flexible Environment runtime.
                        </li>
                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine/guestbook-cloud-datastore"><code>GuestBook</code></a> - An App Engine Standard guestbook that uses Cloud Datastore.
                        </li>
                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/flexible/sparkjava"><code>SparkJava demo</code></a> - Uses google-cloud with App Engine Flexible Environment, Datastore, and SparkJava.
                        </li>
                        <li>
                            <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/datastore"><code>TaskList</code></a> - A command line app that manages a to-do list using Cloud Datastore.
                        </li>
                    </ul>
                </div>
            </section>

            <section class="block faq">
                <div class="container">
                    <h3 class="block-title">FAQ</h3>
		    <h4>What is the relationship between the <code>google-cloud</code> library and the <code>gcloud</code> command-line tool?</h4>
		    <p>Both the <code>gcloud</code> command-line tool and <code>google-cloud</code> library are a part of the Google Cloud SDK: a collection of tools and libraries that enable you to easily create and manage resources on the Google Cloud Platform. The <code>gcloud</code> command-line tool can be used to manage both your development workflow and your Google Cloud Platform resources while the <code>google-cloud</code> library is the Google Cloud Client Library for Java.</p>

		    <h4>What is the relationship between <code>google-cloud</code> and the Google APIs Java Client?</h4>
		    <p>The <a href="https://github.com/google/google-api-java-client">Google APIs Java Client</a> is a client library for using the broad set of Google APIs. <code>google-cloud</code> is built specifically for the Google Cloud Platform and is the recommended way to integrate Google Cloud APIs into your Java applications. If your application requires both Google Cloud Platform and other Google APIs, the 2 libraries may be used by your application.</p>

                    <h4>Does it work on Android?</h4>
                    <p>Android is currently unsupported.</p>
                </div><!-- end of .container -->
            </section><!-- end of .faq -->
        </article><!-- end of .main -->

        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.2.min.js"><\/script>')</script>
        <script src="js/plugins.js"></script>
        <script src="js/vendor/highlight.pack.js"></script>
        <script src="js/main.js"></script>
    </body>
</html>
